home *** CD-ROM | disk | FTP | other *** search
- Path: dartvax.dartmouth.edu!usenet
- From: Mark.A.McPeek@dartmouth.edu (Mark A. McPeek)
- Newsgroups: comp.lang.c++
- Subject: Disk Write Problem
- Date: 22 Jan 1996 18:29:39 GMT
- Organization: Dartmouth College, Hanover, NH
- Message-ID: <4e0l2j$8jr@dartvax.dartmouth.edu>
- NNTP-Posting-Host: atgw-ksp-1-83.dartmouth.edu
- X-Posted-From: InterNews 1.0.6@dartmouth.edu
-
- Hi. I've recently switched programming platforms from Turbo C++ and
- OWL running on a 486 with Windows 3.1 to Borland C++ 4.52 and OWL
- running on a Pentium with Windows 95. I'm trying to convert a program
- across this platform change.
-
- The code below is a segment that is giving me real problems. The code
- attempts to read in a text file of numbers from the harddisk. If I
- comment out all the calls to the harddisk (as I have done below) the
- program runs fine. The file opens and then closes and no errors are
- produced (that I know of). If I remove the comments so that the calls
- are made to the disk, the program runs fine and the program reads all
- the data from the file correctly. However, when I shut down the
- application from the application's menu, I receive a General Protection
- Exception message (Exception 13 to be exact). This code segment ran
- fine (i.e., no GPE generated) on the Windows 3.1 platform.
-
- Can anyone tell me what's going wrong here? I would appreciate any
- advice or suggestions. I do not regularly monitor this news group, so
- please respond to my e-mail address.
-
- Thanks for any help!
-
- Mark McPeek
- mark.mcpeek@dartmouth.edu
-
-
- //**********************************************************************
- *****
-
- void contrastApp::GetData()
- {
- int NumIncomingSpp=0; // Number of species to read from data
- file
-
- strcpy(TreeString,"");
-
- TOpenSaveDialog::TData fileData(OFN_FILEMUSTEXIST| OFN_HIDEREADONLY |
- OFN_PATHMUSTEXIST,"All Files (*.*)|*.*",0, 0, "*");
-
- strcpy(fileData.FileName,"*.*");
-
- if (TFileOpenDialog(GetMainWindow(), fileData).Execute() != IDOK)
- {
- strcpy(msg, "No File was opened.");
- MessageBox(0, msg,"Warning in GetData!", MB_OK | MB_ICONSTOP);
- return;
- };
- ifstream infile(fileData.FileName, ios::in); // Open file for input
- const int bufflength=1000; // Length of Input Buffer
- char inbuf[bufflength]; // Holds Buffer from file
-
- /*
-
- infile.getline(inbuf,bufflength);
- istrstream incoming(inbuf);
-
- incoming >> NumIncomingSpp >> NumChars >> AllBranchesFlag;
- if (AllBranchesFlag==0)
- {
- NumSpp=NumIncomingSpp;
- NumNodes=(2*NumSpp)-1;
- }
- else
- {
- NumSpp=(NumIncomingSpp-1)/2;
- NumNodes=NumIncomingSpp;
- }
-
- if (NumSpp>MaxSpp)
- {
- wsprintf(msg, "Number of Species in Data File too large (i.e., >
- %d)\nProgram Terminating.", MaxSpp);
- MessageBox(0, msg,"Warning!", MB_OK | MB_ICONSTOP);
- NumSpp=0; NumChars=0;
- infile.close(); // Close Raw data file
- exit(0); // Terminate program
- }
- if (NumChars>MaxChars)
- {
- wsprintf(msg, "Number of Characters in Data File too large (i.e., >
- %d)\nProgram Terminating.", MaxChars);
- MessageBox(0, msg,"Warning!", MB_OK | MB_ICONSTOP);
- NumSpp=0; NumChars=0;
- infile.close(); // Close Raw data file
- exit(0); // Terminate program
- }
- HoldData = new RawData[NumIncomingSpp];
- infile.getline(TreeString, bufflength);
-
- for (i=0;i<NumIncomingSpp;i++)
- {
- infile.getline(inbuf,33);
- strcpy(HoldData[i].Name,inbuf); // Assign species label to Nodes
- infile.getline(inbuf,bufflength); // Take in data for this species
- istrstream incoming(inbuf);
- for (int j=0; j<NumChars; j++)
- {
- incoming >> HoldData[i].CharacterData[j];
- }
- }
- */
-
- infile.close(); // Close Raw data file
-
- } // End contrastApp::GetData
-